home *** CD-ROM | disk | FTP | other *** search
- /*
- * Program : DiaSlide.rexx.
- * Version : 1.1 (Added scrolling!)
- * Author : Paul Kolenbrander. Copyright ©1993. All Rights Reserved.
- * Distribution : Non-Commercially only! *Any* vendor or person engaged in any
- * commercial enterprise, wishing to incorporate, give, or in
- * any other way hand-over this script, should first obtain
- * written permission for that from me at the below address
- *
- * Paul Kolenbrander
- * Turfveldenstraat 37
- * NL-5632 XH EINDHOVEN
- * The Netherlands
- * Phone : +31-40-415752 / Fax : +31-40-426446
- * Electronic Mail - InterNet : boinger@myamy.hacktic.nl
- * UseNet : paulk@stack.urc.tue.nl
- * FidoNet : 2:2802/123.1
- * AmigaNet : 39:150/101.1
- * NLA-Net : 14:106/100.1
- * WarpSpeed: 147:1702/2.1
- *
- * Purpose : Display a directory full of pictures with Alexander Pratsch
- * DIA program using random transitions.
- *
- * Usage : rx DiaSlide.rexx [<Directory name> <Delay period>]
- * Directory name - Where this script looks for the pictures.
- * eg. Sys:Pics or Graphics:. When no path is
- * given, the script uses current directory.
- * Delay period - Time to wait between loading pictures in
- * 1/50th of a second. When not specified it
- * defaults to 5 seconds. If you specify a 0
- * the script will wait for you to press the
- * left mousebutton to load in the next file.
- *
- * It would be best to put only picture files in the directory, but this script
- * has rudimentary error-checking and won't really mind other files to be present
- * also. It will slow down performance though as it has to load these.
- *
- * Newly added feature... When you select a delay period by mouse-click (delay = 0)
- * you can now scroll around pictures that are larger than the screen. All around
- * the screen are 25 pixel wide invisibale scroll bars. Click in the appropriate one
- * and the picture will scroll 25 pixels out of that direction... Click anywhere in
- * the picture outside those scrollbars and the next picture is loaded. Where you
- * can also scroll around in.
- *
- * NOTE: Scrolling only works when the loaded picture is LARGER than the screen it is
- * displayed in... And only those hidden parts can be scrolled into sight.
- *
- * Screen & Scroll Bar lay-out...
- *
- * +--------------------------------------+ -
- * | | Scroll Down | | | 25 pixels wide
- * |S |--------------------------------| S| -
- * |c | | c|
- * |r | | r|
- * |o | | o|
- * |l | Exit | l|
- * |l | Scroll | l|
- * | | Routine. | |
- * |R | | L|
- * |i | | e|
- * |g | | f|
- * |h | | t|
- * |t |--------------------------------| | -
- * | | Scroll Up | | | 25 pixels wide
- * +--------------------------------------+ -
- * |--| |--|
- * 25 pixels wide 25 pixels wide
- *
- */
-
- /* Parse the arguments */
- PARSE ARG dirname wait
-
- /* If no directory name has been specified, we just get ourselves the current one. */
- IF dirname = 'dirname' | dirname = '' | dirname = 'DIRNAME' THEN dirname=pragma('D')
-
- /* And if no wait period has been specified, we set a default 5 second wait */
- IF wait = 'wait' | wait = 'WAIT' THEN wait = 250
-
- /* Set the ToolTypes. Please adjust to your own configuration and liking */
- diaName = 'EGS:Piccolo/Dia/Dia "SCREEN=PICOa:SVGA 800x600" DEPTH=16 AUTOCLEAR=OFF DELAY=1';
-
- /* We need the rexxsupport.library, so let's check if it's there */
- IF (~SHOW( 'L', "rexxsupport.library" ) ) THEN DO
- IF (~ADDLIB("rexxsupport.library", 0, -30, 0 )) THEN DO
- EXIT
- END
- END
-
- OPTIONS RESULTS
-
- Max_Seconds_To_Load = 60
- Flag = 0
-
- /* Check if Dia is already running. If not, then start it up. */
- TIME( 'R' )
- DO WHILE (TIME( 'E' ) < Max_Seconds_To_Load) & (POS( 'rainbow', SHOW( 'Ports' ) ) = 0)
- IF Flag = 0 THEN DO
- /* Set whatever command line arguments you want. */
- ADDRESS COMMAND 'run <nil: >nil: ' || diaName;
- Flag = 1
- END
- ADDRESS COMMAND 'WAIT 1'
- END
-
- IF POS( 'rainbow', SHOW( 'Ports' ) ) = 0 THEN DO
- SAY "Could not start up DIA. Exiting!"
- EXIT
- END
-
- filelist=TRANSLATE(SHOWDIR(dirname,'f','0a'x),'80'x,'200a'x)
-
- /* Let's seed the ARexx random generator using the time of day. ;-) */
- which = RANDOM(1,9, TIME('M') + TIME('H'))
-
- AUTOCLEAR OFF
-
- /* Here we get all the filenames and tack a full path to the front of each. */
- i=1
- DO i=1 TO WORDS(filelist)
- filename = TRANSLATE((WORD(filelist,i)),'20'x, '80'x)
- IF ( (RIGHT(dirname, 1) ~= '/') & (RIGHT(dirname, 1) ~= ':') ) THEN dirname=dirname || '/'
- DiaFile=dirname || filename
- CALL ShowDia(Diafile)
- END
- EXIT
-
- /* T-t-t-that's all f-f-f-folks! Y'awl come back now, ya hear. */
-
- /*---------------------------- Subroutine Section ---------------------------*/
-
- ShowDia:
- /* Here we try and load the file. */
- PARSE ARG Diafile
-
- IF EXISTS(Diafile) THEN DO /* existing File ? */
- address "rainbow";
- AUTOCLEAR OFF
-
- /* If you don't like a list of filenames in your CLI, comment the below line out. */
- SAY "loading " || Diafile || "..."
-
- OPTIONS RESULTS
- LOAD Diafile /* If yes, load Picture */
- IF result = 0 THEN DO
- /* we've loaded a valid format. So let's get to work on the transition. */
- CALL Transitie
- IF wait = 0 THEN CALL Scrollem /* Wait for mouseclick? */
- ELSE DELAY wait
- END
- END
- ELSE DO
- say Diafile || " doesn't exist."
- END
- RETURN
-
-
- Transitie:
- /* In this subroutine we determine which transition mode to use. */
- /* First we get a random value. */
- old = which
- which=RANDOM(1,9)
-
- /* little kludge to reduce the possibility of two identical transitions after another. */
- If old = which THEN which=RANDOM(1,9,old * which + i)
-
- /* And here we decide on our lucky winner */
- IF which = 1 THEN transitie=TOP
- IF which = 2 THEN transitie=BOTTOM
- IF which = 3 THEN transitie=LEFT
- IF which = 4 THEN transitie=RIGHT
- IF which = 5 THEN DO
- transitie=CHECKER
- /* And some extra effects for Checker modus */
- block = RANDOM(5,25)
- frame = RANDOM(1,10)
- SETCHECKER block frame
- END
- IF which = 6 THEN transitie=MIDDLE
- IF which = 7 THEN transitie=HALFLINE
- IF which = 8 THEN DO
- transitie=DISSOLVE
- /* A well as for Dissolve modus */
- block = RANDOM(5,30)
- SETDISSOLVE block
- END
- IF which = 9 THEN transitie=BORDER
-
- /* And clear the screen. Unless all the pictures you show are the same size. */
- /* Then you might want to comment out the below CLEARSCREEN line. */
- CLEARSCREEN
-
- SHOW transitie
-
- /* And reset the default values for CHEKER and DISSOLVE modes if need be.*/
- IF which = 5 | which = 8 THEN DO
- SETCHECKER 8 8
- SETDISSOLVE 8
- END
-
- RETURN
-
- Scrollem:
- /* In this subroutine we allow the user to scroll around the picture if it is */
- /* larger than the screen. */
-
- OPTIONS RESULTS
- GET_SW
- scx = result
- GET_SH
- scy = result
- GET_W
- picx = result
- GET_H
- picy = result
-
- /*
- debug info... Uncomment if you like to see what's going on.
- say 'Screen Width : ' || scx
- say 'Screen Height: ' || scy
- say 'Picture Width: ' || picx
- say 'PictureHeight: ' || picy
- end of debug info
- */
-
- einde = 0
- SCROLLING ON
- xpos = 0
- ypos = 0
- DO WHILE einde = 0
- WAITMOUSE /* Wait for mouseclick? */
- /* If clicked, we get the mouse x and y coordinate */
-
- OPTIONS RESULTS
- GET_MX
- mx = result
- GET_MY
- my = result
- /*
- some more debug info...
- say 'Mouse X pos. : ' || mx
- say 'Mouse Y pos. : ' || my
- say 'Pict. X pos : ' || xpos
- say 'Pict. Y pos : ' || ypos
- end the end of it
- */
-
- /* Clicked in the rightmost 25 pixels so we scroll to the left */
- IF (scx - mx) <= 25 THEN DO
- xpos = xpos + 25
- IF xpos > (picx - scx) THEN xpos = picx - scx
- SCROLLTO xpos ypos /* Scroll Right */
- END
-
- /* Clicked in the leftmost 25 pixels, so we scroll to the right */
- IF mx <= 25 THEN DO
- xpos = xpos - 25
- IF xpos < 0 THEN xpos = 0
- SCROLLTO xpos ypos /* Scroll Left */
- END
-
- /* Clicked in the uppermost 25 pixels, so we scroll down */
- IF my <= 25 & mx > 25 & (scx - mx) > 25 THEN DO
- ypos = ypos - 25
- IF ypos < 0 THEN ypos = 0
- SCROLLTO xpos ypos /* Scroll Down */
- END
-
- /* Clicked in the lowermost 25 pixels, so we scroll up */
- IF (scy - my) <= 25 & mx > 25 & (scx - mx) > 25 THEN DO
- ypos = ypos + 25
- IF ypos > (picy - scy) THEN ypos = picy - scy
- SCROLLTO xpos ypos /* Scroll Up */
- END
-
- /* Clicked out of the scroll boxes. Means we exit this scroll routine */
- IF (scx - mx) > 25 & mx > 25 & my > 25 & (scy - my) > 25 THEN
- einde = 1 /* Exit the scroll routine */
- END
-
- RETURN
-